#include "sobel.hh"

IplImage*
sobel (IplImage* input, bool x, bool y)
{
  IplImage* sobel_x = NULL;
  IplImage* sobel_y = NULL;
  if (x)
    sobel_x = convolution (input, 100, 0, -100, 200, 0, -200, 100, 0, -100);
  if (y)
    sobel_y = convolution (input, 100, 200, 100, 0, 0, 0, -100, -200, -100);

  if (x && !y)
    return sobel_x;
  if (!x && y)
    return sobel_y;
  if (x && y)
    return mix (sobel_x, sobel_y, "mean");

  return NULL;
}
